<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.org/rich"
                template="/layout/template_box.xhtml"
                xmlns:a4j="http://richfaces.org/a4j">


  <ui:define name="head">
    <a4j:loadStyle src="/css/custom-theme/jquery-ui-1.8.2.custom.css"/>
    <!-- <a4j:loadScript src="/js/alertaInstituicao.js" />-->


  </ui:define>

  <ui:define name="MenuInterno">
    <ui:include src="/layout/menu_usuario.xhtml"/>
  </ui:define>


  <ui:define name="body">

    <h2 class="t_usuario">
    	Usuários
    </h2>

    <div id="tamanho_div">


      <h:form styleClass="form_confea" ajaxSubmit="true">
  
   <fieldset>
            <legend>Opções de Busca</legend>
            <ol>
           
              <li>

                <s:div id="divNome">
	                <s:decorate id="nomeField" template="/layout/edit.xhtml">
	                  <ui:define name="label">Nome</ui:define>
	                  <h:inputText id="nome" styleClass="campo_full" required="true" requiredMessage="O campo é obrigatório" value="#{usuarioList.usuarioPesquisa.nome}" />
	                    
	                </s:decorate>
                </s:div>

              </li>

            </ol>
            <s:div id="divBotoes">
		        <h:commandLink styleClass="btn" valeu="Pesquisar" action="#{usuarioList.pesquisar}">Pesquisar</h:commandLink>
		        <h:commandLink styleClass="btn" valeu="Limpar" immediate="true" action="#{usuarioList.listar}" onclick="jQuery('[id$=nome]').val('')">Limpar</h:commandLink>
	        </s:div>
          </fieldset>
  
  
  
  
        <fieldset>
          <s:div rendered="#{listaUsuarios.size == 0}">
            <p class="tool_alerta"> Nenhum Usuário encontrado.</p>
          </s:div>

          <rich:dataTable value="#{listaUsuarios}" var="_usuario" styleClass="grid_dados" cellpadding="0" cellspacing="0"
          border="0"  id="usuarioLista" rows="#{usuarioList.paginacao}"
          rowClasses="grid_zebra,none">
        
            <rich:column >
              <f:facet name="header">Nome</f:facet>
              <h:outputText value="#{_usuario.nome}"/>
            </rich:column>


            <rich:column style="width:15%">
              <f:facet name="header">Ações</f:facet>
                <span>
                    <s:link title="Editar Usuário"                 
                    id="btnEditar" styleClass="editar2" view="/usuario/usuario.xhtml" propagation="none">
	                   <f:param name="idUsuario" value="#{_usuario.id}"/>
                    </s:link>


	   				<a4j:commandLink title="Trocar senha" styleClass="senha" id="showItem" ajaxSingle="true" immediate="true" action="#{declaracaoList.selecionar(_declaracao)}" oncomplete="Richfaces.showModalPanel('panel',{width:550, top:200});" limitToList="true" reRender="panel" >
	   					<f:setPropertyActionListener target="#{usuarioList.usuario}" value="#{_usuario}" />
	   				</a4j:commandLink>



		     	  	<h:commandLink title="Desativar" id="btnExcluir" immediate="true"
                   
                    styleClass="excluir2" action="#{usuarioList.desativar()}"
                    onclick="return confirm('Confirmar desativação?')">
                    </h:commandLink>

   	  			
   	  			</span>
            </rich:column>

          </rich:dataTable>
          <rich:datascroller id="scrolInstituicao"
            for="usuarioLista" maxPages="#{usuarioList.paginacao}"
            align="center" renderIfSinglePage="false"  />

        </fieldset>
      </h:form>
      <rich:modalPanel id="panel" width="550" autosized="true">
	        <f:facet name="header">
	            <h:panelGroup>
	                <h:outputText value="Alterar Senha do Usuário #{usuarioList.usuario.nome}"></h:outputText>
	            </h:panelGroup>
	        </f:facet>
	        <f:facet name="controls">
	            <h:panelGroup>
	                <h:graphicImage value="/imagens/close.png" styleClass="hidelink" id="hidelink"/>
	                <rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>
	            </h:panelGroup>
	        </f:facet>
	      
	         <div id="conteudo_pagina" >
       	<div id="tamanho_div" >
		   		<a4j:form id="formGeraDeclaracao" styleClass="form_confea">
					<a4j:outputPanel id="panelDeclaracaoForm" ajaxRendered="true">
					<s:validateAll>
					<fieldset>
	            <ol>
	           
	          			 <li>
								<fieldset>
									<legend>
										<h:outputText value="Nova senha" />
									</legend>
								</fieldset>
							</li>
							

					<li><s:decorate template="/layout/edit.xhtml" id="decoSenha" >
						<ui:define name="label">
							Senha
						</ui:define>
						<h:inputSecret immediate="true" id="senha" required="true" requiredMessage="O campo 'Senha' é obrigatório" styleClass="campo_full" value="#{usuarioList.usuario.senha}" >
						</h:inputSecret>													
						
					</s:decorate></li>
					
					<li><s:decorate template="/layout/edit.xhtml" id="decoSenhaC" >
						<ui:define name="label">
							Confirmação
						</ui:define>
						<h:inputSecret id="senhaC" required="true" requiredMessage="O campo 'Confirmação' é obrigatório" styleClass="campo_full" value="#{usuarioList.confirmacao}" >
							<a4j:support event="onchange" reRender="confirmacao" limitToList="true" ajaxSingle="true" eventsQueue="default"/>
						</h:inputSecret>													
						
					</s:decorate></li>
	
	            </ol>
	            </fieldset>
	            <fieldset>
							<h:messages globalOnly="true" styleClass="tool_alerta" />
						</fieldset>
	            <s:div id="divBotoes">
						<a4j:commandLink styleClass="btn"
								action="#{usuarioList.salvar()}"   
								 value="Salvar" limitToList="true" eventsQueue="default" 
								reRender="formGeraDeclaracao" />
						
					<s:link styleClass="btn" value="Fechar" id="btnFecharModal"/>	
	                <rich:componentControl for="panel" attachTo="btnFecharModal" operation="hide" event="onclick"/>

		        </s:div>  
		        </s:validateAll>
					</a4j:outputPanel>
					</a4j:form>
					</div>
					</div>
					
	    </rich:modalPanel>

    </div>
  </ui:define>

</ui:composition>
